<script setup>
import { getUserData } from '../../utils';
import banner from '../../components/Banner.vue'
import teacherBanner from '../../components/TeacherBanner.vue'
import { ref, watch, reactive } from 'vue';
import axios from 'axios';
const nowPage = ref(4);
const searchCon = ref();


// 获得用户信息
// 获得用户信息
let userData = reactive({
    Token: '',
    avatar: '',
    id: '',
    role: ''
})
if(getUserData() != undefined){
    userData = getUserData();
}
console.log(userData);

//得到当前登录状态
const getBanner = ref(banner);
function getState(){
    if(userData.Token != '')
    {
        getBanner.value = teacherBanner;
    }
    else{
        getBanner.value = banner;
    }
}
getState();
// 未搜索，页面默认的内容
// const defaultData = {
//     currentPage: 1
// }
// axios({
//     headers: {
//         'Content-Type': 'application/json; charset=utf-8'
//     },
//     method: 'post',
//     url: 'http://api.linwine.space/api/sjk/main/search_result',
//     data: JSON.stringify(defaultData),
//     responseType: "json",
// }).then((data) => {
//     console.log(data);
//     total.value = data.data.data.total;
//     pageSize = data.data.data.pageSize;
// }).catch((data) => {
//     console.log('error');
//     console.log(data);
// })

watch(()=>searchCon.value, ()=>{
    console.log(searchCon.value);
})

//提交要搜索的内容
const submit = function () {
    const data = {
        context: searchCon.value
    }
    axios({
        headers: {
            'Content-Type': 'application/json; charset=utf-8',
            'Token': userData.Token
        },
        method: 'post',
        url: '/path/main/about',
        responseType: "json",
        data: JSON.stringify(data)
    }).then((data) => {
        const curPage = {
            currentPage: currentPage
        }
        console.log(data);
        console.log(data.data.code);
        if (data.data.code == 200) {                    //搜索成功获得结果
            // axios({
            //     headers: {
            //         'Content-Type': 'application/json; charset=utf-8'
            //     },
            //     method: 'post',
            //     url: 'http://api.linwine.space/api/sjk/main/search_result',
            //     data: JSON.stringify(curPage),
            //     responseType: "json",
            // }).then((data) => {
            //     console.log(data);
            //     total.value = data.data.data.total;
            //     pageSize = data.data.data.pageSize;
            // }).catch((data) => {
            //     console.log('error');
            //     console.log(data);
            // })
        }
        else {
        }
    }).catch((data) => {
        console.log('error');
        console.log(data);
    })
}

</script>
<template>
    <component :nowPage="nowPage" :is="getBanner"/>
    <div class="container">
        <p class="text">抱歉！内容不开放</p>
    </div>
</template>
<style scoped>
.container {
    width: 100%;
    height: 100%;
    background-color: #f1f2f6;
    padding-top: 17%;
    min-height: 500px;
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    align-items: center;
}
.text{
    font-family: Source Han Sans CN;
	font-size: 40px;
	font-weight: normal;
	font-stretch: normal;
	line-height: 68px;
	letter-spacing: 0px;
	color: #707070;
}

.search {
    width: 100%;
    min-width: 300px;
    height: 50%;
    display: flex;
    justify-content: center;
    background-color: aqua;
    margin-top: 4%;
}

.searchCon {
    width: 30%;
    height: 40px;
}

.result {
    width: 100%;
    height: 100%;
    background: pink;
}

.subBut {
    width: 5%;
    height: 40px;
}

.pagination {
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: center;
}
</style>